<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>用户登录</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="{$smarty.const.PUBLIC_PATH}css/amazeui.min.css"/>
<link rel="stylesheet" href="{$smarty.const.IMAGES_PATH}style.css"/>
<script src="{$smarty.const.PUBLIC_PATH}js/jquery.min.js"></script>
<script src="{$smarty.const.PUBLIC_PATH}js/amazeui.min.js"></script>
<script type="text/javascript">
	window.onload=function(){
		var token=Date.parse(new Date())+Math.ceil(Math.random()*1000);
		$("#wxqccode").attr("src",$("#wxqccode").attr("src")+token);
//		alert($("#wxqccode").attr("src"));
		setInterval(function(){
			//每0.5秒检测一次用户是否已经扫码登录
			$.post("{$smarty.const.__CONTROLLER__}/whether_wx_login", { token:token}, function(ret){
				console.log(ret);
				if(ret){
					$.post("{$smarty.const.__CONTROLLER__}/had_wx_login", { id:ret}, function(ret2){
						if(ret2.error){
							$("#tip").text('扫码登录成功，即将跳转');
							window.location.href="{$smarty.const.__CONTROLLER__}/index";
						}else{
//							alert(ret2.tip);
						}
					})
				}
			})
		},3000);
	}
</script>
</head>

<body>
<div class="container" style="position: relative;">
	<!--引入头文件-->
	{include file="../header.html"}
	<script>$('.title-link').text("用户登录")</script>
    <div class="cart-panel" style="min-height: 600px;">
            <div class="am-form-group am-form-icon">
                <i class="am-icon-user" style="color:#329cd9"></i>
                <input type="text" name="name" id="name" class="am-form-field  my-radius" placeholder="请输入您的用户名">
            </div>
            <div class="am-form-group am-form-icon">
                <i class="am-icon-lock" style="color:#329cd9"></i>
                <input type="password" name="password" id="password" class="am-form-field  my-radius" placeholder="请输入您的密码">
            </div>
            <div class="am-checkbox">
            	<p>关注公众号即可微信登录,点击<a style="color: red;" class="showqccode">显示二维码</a></p>
                <p><button class="am-btn am-btn-success am-radius am-btn-block towxlogin" style="width: 100px;left: 0;">微信登录</button></p> 
            </div>
            <div class="withdrawals-panel" style="margin-top: 15px;display: none;">
            	<p class="am-text-center"><img src="{$smarty.const.REDIRECT_URL}" id="wxqccode" class="qrcode-qrcode" /></p>
        		<p class="am-text-center" id="tip"></p>
            </div>
            <p class="am-text-center"><button  class="am-btn am-btn-danger am-radius am-btn-block loginbt">立即登录</button></p>
    </div>
    
    <div class="pwddiv" style="position: absolute;top:0;z-index: 999;background: rgba(0,0,0,0.5);width:100%;height: 100%;display: none;">
		<form class="am-form" style="position: absolute;top:20%;left:20%;width:60%;background-color: white;padding: 10%;" >
        	<div class="withdrawals-panel" style="margin-top: 15px;border: solid 1px white;">
            	<p class="am-text-center"><img src="{$smarty.const.IMAGES_PATH}qccode.jpg" id="wxqccode" class="qrcode-qrcode" /></p>
        	</div>
		</form>
    </div>
    
    <footer data-am-widget="footer" class="am-footer am-footer-default" data-am-footer="{  }">
        <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
      <div class="am-footer-miscs ">
        <p>CopyRight©2014 AllMobilize Inc.</p>
        <p>京ICP备13033158</p>
      </div>
    </footer>
    
    <!--底部-->
    {include file="../footer.html"}
    </div>
      <script src="/Home/Public/js/jquery.min.js"></script>
	  <script>
		$('.loginbt').click(function(){
			var name=$('#name').val();
			var password=$('#password').val();
			if(name==''){
				alert("账号不能为空");
			}else if(password==''){
				alert("密码不能为空");
			}
			else{
				var data={
				name:name,
				password:password,
			};
			console.log(data);
			$.post("{$smarty.const.__SELF__}", data, function(ret){
				//console.log(ret);
				if(ret.error==0){
					location.href="{$smarty.const.__MODULE__}/User/index";
				}else{
					alert(ret.tip);
				}
			})
			}
		})
		var flag=true;
		$(".towxlogin").click(function(){
			if(flag){
				$(".withdrawals-panel").slideDown();
				flag=!flag;
			}else{
				$(".withdrawals-panel").slideUp();
				flag=!flag;
			}
			
		})
		$('.showqccode').click(function(){
			$('.pwddiv').fadeIn();
		})
		$('.pwddiv').click(function(){
			$('.pwddiv').fadeOut();
		})
	  </script>

</body>
</html>
